web3.tokyo NFT
Chain: Polygon Mainnet
Contract Address: 0xe46A2FFcF1Fb35CCc703d0D0414a931Bd658Da02
code:web3tokyo.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/Base64.sol";
contract Web3Tokyo is ERC721Enumerable, Ownable {
using Strings for uint256;
// tokenId => blockId
mapping(uint256 => uint256) public blockIds;
constructor() ERC721("web3.tokyo", "W3T") {
}
function imageData(uint256 tokenId)
internal
view
returns (string memory)
{
bytes memory data = abi.encodePacked(
'PoA at web3.tokyo block',
'</text></svg>'
);
return string(
abi.encodePacked(
"data:image/svg+xml;base64,",
Base64.encode(data)
)
);
}
function tokenURI(uint256 tokenId)
public
view
override
returns (string memory)
{
require(_exists(tokenId));
bytes memory data = abi.encodePacked(
'{',
'"name": "web3.tokyo #', tokenId.toString(), '",', '"block": "', blockIdstokenId.toString(), '",', '"image": "', imageData(tokenId), '"',
'}'
);
return string(
abi.encodePacked(
"data:application/json;base64,",
Base64.encode(data)
)
);
}
function mint(address beneficiary, uint256 blockId)
onlyOwner
public
{
_mint(beneficiary, totalSupply());
}
function withdraw() external onlyOwner {
payable(owner()).transfer(address(this).balance);
}
receive() external payable {}
}
Deployment Cost
https://scrapbox.io/files/63d8d865ca7c6c001de4437e.png